package com.zwj.common;

import lombok.Data;


@Data
@SuppressWarnings("all")
public class R<T> {

    private Integer code; //编码

    private String msg; //错误信息

    private T data; //数据


    /**
     * 成功返回
     * @param object
     * @param <T>
     * @return
     */
    public static <T> R<T> success(T object) {
        R<T> r = new R<T>();
        r.data = object;
        r.code = ResultCode.SUCCESS.getCode();
        return r;
    }

    /**
     * 错误返回
     * @param msg
     * @param <T>
     * @return
     */
    public static <T> R<T> error(String msg) {
        R r = new R();
        r.msg = msg;
        r.code = ResultCode.FAILED.getCode();
        return r;
    }


}
